#------------------------------------------
# VisualK-OS                               
#    Module: Main Menu Screen Class [v1.0] 
#    Author: Kevin Slaughter               
#------------------------------------------

"""
[Revision History]
    v1.0: Initial implementation... Having the screens encapsulated by
            the ScreenManager class with if-then-else blocks worked at
            first, when not much as required of the program, but more
            complex classes arose out of necessity to shrink/simplify
            the growing source code.
"""

import globals
from VKCC_Constants import *


class cScreenMain(object):
    ### General properties
    color = 1                               # Color theme used within this screen
    title = "VisualK-OS Control Center"     # Title to be displayed
    hasExit = False                         # Flag: Display exit option
    
    
    ### handleKey(): Handle any passed keyboard input independent of GP usage.
    def handleKey(self, c, scr):
        if (c == KEY_ASTERISK):     # '*' = Mute on/off
            globals.muteAll = not globals.muteAll
            scr.redraw = True	    # Trigger re-draw

        elif (c == KEY_1): # 1= Client Scan
            scr.changeScreen(SCREEN_SCAN)

        elif (c == KEY_2): # 2 = Configure Devices
            scr.changeScreen(SCREEN_CFG_MAIN)

        elif (c == KEY_3): # 3 = Gamepad Mapping
            scr.changeScreen(SCREEN_MAPPING)
        
        elif (c == KEY_5): # 5 = Notify test
            scr.showNotification("MOO")
        
        elif (c == KEY_9): # 9 = Manual FBA Control
            scr.changeScreen(SCREEN_MANUAL_FBA)
        
        else: scr.printText(3,14, "GOT KEY: "+str(c), T_ERROR)
        return
    
    
    ### paint(): Draw any elements used on this screen.
    def paint(self, scr):
        scr.menuPrep(self)	# Base framework
        
        # Menu items
        scr.printText(2,4, "1.) Scan for Slave Devices")	# Scan for slave devices (FBA/Thor/etc)
        scr.printText(2,5, "2.) Configure Client Modules")	# Configure slave devices
        scr.printText(2,6, "3.) Display GamePad Mapping")	# Displays current gamepad cfg
        scr.printText(2,7, "4.) "); scr.printNA(6,7)		# n/a
        scr.printText(2,8, "5.) "); scr.printNA(6,8)		# n/a
        scr.printText(2,9, "6.) "); scr.printNA(6,9)		# n/a
        scr.printText(2,10,"7.) "); scr.printNA(6,10)		# n/a
        scr.printText(2,11,"8.) "); scr.printNA(6,11)		# n/a
        scr.printText(2,12,"9.) Manual FBA Control")		# Keyboard-driven FBA control
        
        # Current GamePad map index
        scr.printText(1,(globals.MAX_Y-1), "[GP Map: "+str(globals.GP.curMap)+"]", T_HIGHLIGHT)
        
        # Mute indicator & version
        self.showMuteIndicator()
        self.showVersion()
        return


    ### showMuteIndicator(): Standardization/lazy macro; Displays state of master mute.
    def showMuteIndicator(self):
        sMute = "[ON]" if (globals.muteAll) else "[off]"
        globals.SM.printText(((globals.MAX_X/2)-7),(globals.MAX_Y-1), "[*] MUTE ALL "+sMute, T_HEADER)
        return
    
    
    ### showVersion(): Standardization/lazy macro; Displays program verison.
    def showVersion(self):
        # Display version info in lower-right corner
        globals.SM.printText((globals.MAX_X-len(VERSION_STR)-1),(globals.MAX_Y-1), VERSION_STR, T_HIGHLIGHT);
        return
    